package com.tjmc.tiomsresource.parser;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author Luc
 * @version 1.0
 * @date 2020-05-12 13:58
 */
public abstract class AbstractParser<T> {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    protected static final int PRINT_LOG_SPLIT = 3000;

    protected SAXReader saxReader = new SAXReader();

    public List<Element> parseXML(String filePath) throws DocumentException {
        logger.info("===parse" + this.getClass() + ":" + filePath);
        Document document = saxReader.read(filePath);
        return document.selectNodes("/DataFile/Objects/FieldValue/Object");
    }

    public abstract List<T> parseXML(List<Element> objectElements);
}
